package com.zijie.members.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zijie.members.model.Members;
import com.zijie.members.model.MembersAddress;
import com.zijie.members.model.search.MemberAddressSearchBean;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MemberAddressMapper extends BaseMapper<MembersAddress> {
    //查询全部方法：
    default Page<MembersAddress> findAll(Page<MembersAddress> page, MemberAddressSearchBean memberAddressSearchBean) {
        LambdaQueryWrapper<MembersAddress> queryWrapper = Wrappers.lambdaQuery(memberAddressSearchBean);
        return selectPage(page, queryWrapper);
    }


    @Update("update member_address set addr_detail=#{addrDetail} where member_id = #{id}")
    void updateByMember(Members members);

    @Insert("insert into member_address(member_id,addr_detail) values(#{id},#{addrDetail})")
    int insertByMenber(Members members);

    @Delete("delete from member_address where member_id = #{id}")
    void deleteByMemberId(Integer id);

    @Select("select count(1) from member_address where member_id = #{id}")
    int eqByMemberId(Integer id);


    void deleteByMemberIds(List<Integer> ids);
}
